﻿using System.Collections.Generic;
using System.Linq;
using EzDesk.Core.Model;
using EzDesk.DesktopClient.AppModule.ViewContract;
using EzDesk.DesktopClient.MVVMEnhance;
using EzDesk.DesktopClient.ServiceLocator.CoreClientService;

namespace EzDesk.DesktopClient.AppModule.ViewModel
{
    public class AppFunctionCategoryViewModel : ViewModelWithSingleContainer<IAppFunctionCategoryView>
    {
        public FunctionType FunctionTypeModel { get; set; }
        public FunctionCategory FunctionCategoryModel { get; set; }
        public IList<AppFunctionViewModel> AppFunctionViewModelCollection { get; set; }

        public AppFunctionCategoryViewModel(FunctionType functionType, FunctionCategory functionCategory)
        {
            FunctionTypeModel = functionType;
            FunctionCategoryModel = functionCategory;
            AppFunctionViewModelCollection =
                AppManagement.Instance.GetFunction(FunctionTypeModel, FunctionCategoryModel)
                    .Select(af => new AppFunctionViewModel(af))
                    .ToList();
        }
    }
}